<!-- 时间组件 -->
<template>
	<view class="my_page">
		<view class="dates-box f-column">
			<view class="dates f-row-between">
				<view class="date f-center" :style="{ width: 100 / dateTypes.length - 3 + '%' }" v-if="dateTypes.indexOf('d') > -1"
				 :class="selected == 'd' ? 'selected' : ''" @click="onDateType('d')">
					日
				</view>
				<view class="date f-center" :style="{ width: 100 / dateTypes.length - 3 + '%' }" v-if="dateTypes.indexOf('mz') > -1"
				 :class="selected == 'mz' ? 'selected' : ''" @click="onDateType('mz')">
					周
				</view>
				<view class="date f-center" :style="{ width: 100 / dateTypes.length - 3 + '%' }" v-if="dateTypes.indexOf('m') > -1"
				 :class="selected == 'm' ? 'selected' : ''" @click="onDateType('m')">
					月
				</view>
				<view class="date f-center" :style="{ width: 100 / dateTypes.length - 3 + '%' }" v-if="dateTypes.indexOf('y') > -1"
				 :class="selected == 'y' ? 'selected' : ''" @click="onDateType('y')">
					年
				</view>
			</view>
			<view style="width: 100%;" class="f-row-WHcenter" v-show="selected == 'm'">
				<view class="icons iconarrow-left" @click="onSwiperLeft"></view>
				<view class="uni-margin-wrap f-row-Hcenter" :class="selected">
					<swiper class="swiper f-row-Hcenter" @click="onSwiperDate" @change="onChangeSwiper" circular :indicator-dots="indicatorDots"
					 :current="current" :autoplay="autoplay" :interval="interval" :duration="duration">
						<swiper-item class=" f-row-Hcenter" v-for="(item, index) in months" :key="index">{{ year }}年 - {{ item + 1 }}月</swiper-item>
					</swiper>
				</view>
				<view class="icons iconarrow-right" @click="onSwiperRight"></view>
			</view>
			<view style="width: 100%;" class="f-row-WHcenter" v-show="selected == 'y'">
				<view class="icons iconarrow-left" @click="onSwiperLeft"></view>
				<view class="uni-margin-wrap f-row-Hcenter" :class="selected">
					<swiper class="swiper f-row-Hcenter" @click="onSwiperDate" @change="onChangeSwiper" circular :indicator-dots="indicatorDots"
					 :current="current" :autoplay="autoplay" :interval="interval" :duration="duration">
						<swiper-item class=" f-row-Hcenter" v-for="(item, index) in years" :key="index">{{ item }}年</swiper-item>
					</swiper>
				</view>
				<view class="icons iconarrow-right" @click="onSwiperRight"></view>
			</view>
			<view style="width: 100%;" class="f-row-WHcenter" v-show="selected == 'd'">
				<view class="icons iconarrow-left" @click="onSwiperLeft"></view>
				<view class="uni-margin-wrap f-row-Hcenter" :class="selected">
					<swiper class="swiper f-row-Hcenter" @click="onSwiperDate" @change="onChangeSwiper" circular :indicator-dots="indicatorDots"
					 :current="current" :autoplay="autoplay" :interval="interval" :duration="duration">
						<swiper-item class=" f-row-Hcenter" v-for="(item, index) in days" :key="index">{{ year }} - {{ month  }} -
							{{ item }}</swiper-item>
					</swiper>
				</view>
				<view class="icons iconarrow-right" @click="onSwiperRight"></view>
			</view>
			<view style="width: 100%;" class="f-row-WHcenter" v-show="selected == 'mz'">
				<view class="icons iconarrow-left" @click="onSwiperLeft"></view>
				<view class="uni-margin-wrap f-row-Hcenter" :class="selected">
					<swiper class="swiper f-row-Hcenter" @click="onSwiperDate" @change="onChangeSwiper" circular :indicator-dots="indicatorDots"
					 :current="current" :autoplay="autoplay" :interval="interval" :duration="duration">
						<swiper-item class=" f-row-Hcenter" v-for="(item, index) in weeks" :key="index">{{ item }}</swiper-item>
					</swiper>
				</view>
				<view class="icons iconarrow-right" @click="onSwiperRight"></view>
			</view>
		</view>
		<!-- <view class="uni-padding-wrap">
			<view class="uni-title">日期：{{ year }}年{{ month }}月{{ day }}日</view>
		</view> -->
		<view class="datePopup-box">
			<uni-popup id="datePopup" ref="datePopup" :type="'bottom'" @change="change">
				<!--  -->
				<picker-view class="picker-view f-row-Wcenter" :indicator-style="indicatorStyle" v-model="valuedate" @change="bindChange"
				 v-if="selected == 'y'">
					<picker-view-column class="picker-view" style="width: 200upx;">
						<view class="item f-center" v-for="(item, index1) in years" :key="index1">{{ item }}年</view>
					</picker-view-column>
				</picker-view>
				<picker-view class="picker-view f-row-Wcenter" :indicator-style="indicatorStyle" v-model="valuedate" @change="bindChange"
				 v-if="selected == 'm'">
					<picker-view-column class="picker-view" style="width: 200upx;">
						<view class="item f-center" v-for="(item, index1) in years" :key="index1">{{ item }}年</view>
					</picker-view-column>
					<picker-view-column class="picker-view" style="width: 200upx;">
						<view class="item f-center" v-for="(item, index2) in months" :key="index2">{{ item + 1 }}月</view>
					</picker-view-column>
				</picker-view>

				<picker-view class="picker-view f-row-Wcenter" :indicator-style="indicatorStyle" v-model="valuedate" @change="bindChange"
				 v-if="selected == 'mz'">
					<picker-view-column class="picker-view" style="width: 200upx;">
						<view class="item f-center" v-for="(item, index1) in years" :key="index1">{{ item }}年</view>
					</picker-view-column>
					<picker-view-column class="picker-view" style="width: 200upx;">
						<view class="item f-center" v-for="(item, index2) in months" :key="index2">{{ item + 1 }}月</view>
					</picker-view-column>
					<picker-view-column class="picker-view" style="width: 900upx;">
						<view class="item f-center" v-for="(item, index4) in weeksM[year][month]" :key="index4">{{ item.week }}</view>
					</picker-view-column>
				</picker-view>

				<picker-view class="picker-view f-row-Wcenter" :indicator-style="indicatorStyle" v-model="valuedate" @change="bindChange"
				 v-if="selected == 'd'">
					<picker-view-column class="picker-view" style="width: 200upx;">
						<view class="item f-center" v-for="(item, index1) in years" :key="index1">{{ item }}年</view>
					</picker-view-column>
					<picker-view-column class="picker-view" style="width: 200upx;">
						<view class="item f-center" v-for="(item, index2) in months" :key="index2">{{ item + 1 }}月</view>
					</picker-view-column>
					<picker-view-column class="picker-view" style="width: 900upx;">
						<view class="item f-center" v-for="(item, index5) in days" :key="index5">{{ item }}日</view>
					</picker-view-column>
				</picker-view>
				<picker-view class="picker-view f-row-Wcenter" :indicator-style="indicatorStyle" v-model="valuedate" @change="bindChange"
				 v-if="selected == 'z'">
					<picker-view-column class="picker-view" style="width: 900upx;">
						<view class="item f-center" v-for="(item, index3) in weeks" :key="index3">{{ item }}</view>
					</picker-view-column>
				</picker-view>
				<view style="width: 100%;" class="btn-Block f-center">
					<view class="btn-left f-center" @click="onCancel">取消</view>
					<view class="btn-right f-center" @click="onDataSubmit">确定</view>
				</view>
			</uni-popup>
		</view>
	</view>
</template>

<script>
	import {
		year,
		month,
		day,
		years,
		months,
		days,
		p_currents
	} from './date.js';
	export default {
		components: {},

		data() {

			return {
				years,
				year,
				months,
				month,
				days,
				day,
				valuedate: [1, 1, 1],
				p_currents,
				/**
				 * 解决动态设置indicator-style不生效的问题
				 */
				indicatorStyle: `height: ${Math.round(uni.getSystemInfoSync().screenWidth / (750 / 100))}px;`,
				selected: 'mz',
				dateType: 'mz', //上次选中的
				y: '',
				m: '',
				d: '',
				date: '',
				//显示的日期
				weeksM: {}, //每月对应的周
				tmpWeek: '',
				weeks: [],
				week: {
					index: 0, //当前周的下标
					day: false,
					week: '' //当前周
				},
				dates: [],
				indicatorDots: false,
				autoplay: false,
				interval: 200,
				duration: 200,
				current: 0,
				//滑动缓存下标
				currents: {
					y: 2,
					m: 2,
					mz: -1,
					d: 2
				},

				move: true,
				dayClass: '',
				onSwiperDate1: true
			};
		},
		created() {
			// console.log('11111111111',date3.getFullYear(),date3.getMonth(),date3.getDate())
			this.init();
			//console.log(this.year, this.month, this.day, this.years, this.months, this.days);
			this.$on('onSubmitSend', o => {
				this.onSubmit();
			});
		},
		props: {
			dateTypes: {
				type: Array,
				default () {
					return ['mz', 'm', 'y'];
				}
			}
		},
		computed: {},
		methods: {
			onDataSubmit() {
				this.onSubmit();
			},
			onSubmit(refs) {
				//数据参考bindChange事件

				//console.log('onSubmit事件>>>>>', this.valuedate, this.p_currents[this.selected].current);

				//左右滑动 会立马执行  用于快捷时间查询(可以取到vm.data的默认,不至于没选时间提交错误的时间)
				var index = this.weeksM[this.years[this.p_currents.mz[0]]][this.p_currents.mz[1] + 1][this.p_currents.mz[2]].weeksIndex;
				this.week.week = this.weeks[index];
				switch (this.selected) {
					case 'mz':
						this.year = this.years[this.p_currents.mz[0]];
						this.month = this.p_currents.mz[1] + 1;
						break;
					case 'm':
						this.year = this.years[this.p_currents.m[0]];
						this.month = this.p_currents.m[1] + 1;
						break;
					case 'y':
						this.year = this.years[this.p_currents.y[0]];
						break;
					case 'd':
						this.year = this.years[this.p_currents.d[0]];
						this.month = this.p_currents.d[1] + 1;
						break;
					case 'z':
						break;
				}

				let data = {
					events: 'onSubmit',
					anatype: 0, //周年月 类型
					dateSelect: [],
					dateType: this.selected,
					week: this.week.week,
					year: this.year,
					month: this.month,
					day: this.day,
					maxDay: this.days[this.month].length,
					daysM: this.days[this.month],
					start_date: '',
					end_date: ''
				};
				data.dateSelect = data.week.split('—');
				//根据不同的 时间格式 转换 时间截
				if (data.dateType == 'mz') {
					data.anatype = 1;
					data.start_date = new Date(data.dateSelect[0]).getTime();
					data.end_date = new Date(data.dateSelect[1]).getTime();
				}
				if (data.dateType == 'm') {
					data.anatype = 2;
					data.start_date = new Date(data.year + '-' + data.month + '-' + 1).getTime();
					data.end_date = new Date(data.year + '-' + data.month + '-' + data.maxDay).getTime();
				}
				if (data.dateType == 'y') {
					data.anatype = 3;
					data.start_date = new Date(data.year + '-01-' + 1).getTime();
					data.end_date = new Date(data.year + '-12-' + 31).getTime();
				}
				if (data.dateType == 'd') {
					data.anatype = 4;
					data.start_date = new Date(data.year + '-' + data.month + '-' + data.day).getTime();
					data.end_date = data.start_date;
				}
				this.$emit('onSubmit', data);
				//console.log('onSubmit提交', data);
				if (refs != 'datePopup') {
					this.$refs.datePopup.close();
				}
			},
			onCancel() {
				this.$emit('onCancel', {
					events: 'onCancel'
				});
				this.$refs.datePopup.close();
			},
			/**
			 * popup 状态发生变化触发
			 * @param {Object} e
			 */
			change(e) {
				//console.log('change事件  popup ' + e.type + ' 状态', e.show,'----swiperlock',this.swiperlock ,this.valuedate);

			},
			onSwiperLeft() {
				if (this.current <= 0) {
					this.current = this.current + this.dates.length - 1;
				} else {
					this.current = this.current - 1;
				}
				this.onSwiperDate1 = true;
				switch (this.selected) {
					case 'z':
						break;
					case 'mz':
						//valuedate要放在外面
						this.valuedate = [0, 0, 0];
						this.$nextTick(function() {
							this.week.week = this.dates[this.current];
							let week = this.week.week.split('—');
							let week1 = week[0].split('-');
							week1[0] = parseInt(week1[0]);
							week1[1] = parseInt(week1[1]);
							let weeksM = this.weeksM[week1[0]][week1[1]];
							let ok = false;
							for (let i = 0, len = weeksM.length; i < len; i++) {
								if (weeksM[i].weeksIndex == this.current) {
									let data = [];

									data.push(this.years.indexOf(week1[0]));
									data.push(week1[1] - 1);
									data.push(i);
									this.valuedate = data;
									this.p_currents.mz = data;
									//年月下拉定位
									this.year = week1[0];
									//月和滑动月统一，再提交
									this.month = week1[1] - 1;
									ok = true;
									this.onSwiperDate1 = false;
								}
							}
							let week2 = week[1].split('-');
							if (!ok) {
								week2[0] = parseInt(week2[0]);
								week2[1] = parseInt(week2[1]);
								weeksM = this.weeksM[week2[0]][week2[1]];
								for (let j = 0, len = weeksM.length; j < len; j++) {
									if (weeksM[j].weeksIndex == this.current) {
										let data = [];

										data.push(this.years.indexOf(week2[0]));
										data.push(week2[1] - 1);
										data.push(j);
										this.valuedate = data;
										this.p_currents.mz = data;
										//年月下拉定位
										this.year = week2[0];
										//月和滑动月统一，再提交
										this.month = week2[1] - 1;
										ok = true;
										this.onSwiperDate1 = false;
									}
								}
							}
							this.onSubmit();
						});
						break;
					case 'm':
						//valuedate要放在外面
						this.valuedate = [0, 0];
						this.$nextTick(function() {
							this.month = parseInt(this.dates[this.current]);
							//年月下拉定位
							let data = [];
							data.push(this.years.indexOf(this.year));
							data.push(this.month - 1);
							this.valuedate = data;
							this.p_currents.m = data;
							this.p_currents.m.current = this.current;
							this.onSubmit();
						});
						break;
					case 'y':
						//valuedate要放在外面
						this.valuedate = [0];
						this.$nextTick(function() {
							this.year = parseInt(this.dates[this.current]);
							//年月下拉定位
							let data = [];
							console.log(this.year, this.years.indexOf(this.year), this.years);
							data.push(this.years.indexOf(this.year));
							this.valuedate = data;
							this.p_currents.y = data;
							this.p_currents.y.current = this.current;
							this.onSubmit();
						});
						break;
					case 'd':
						//valuedate要放在外面
						this.valuedate = [0, 0, 0];
						this.$nextTick(function() {
							this.day = parseInt(this.dates[this.current]);
							//天下拉定位
							let data = [];
							console.log('天', this.day);
							data.push(this.years.indexOf(this.year));
							data.push(this.month - 1);
							data.push(this.current);
							this.valuedate = data;
							this.p_currents.d = data;
							this.p_currents.d.current = this.current;
							this.onSubmit();
						});
						break;
				}
			},
			onSwiperRight() {
				if (this.current >= this.dates.length - 1) {
					this.current = 0;
				} else {
					this.current = this.current + 1;
				}
				this.onSwiperDate1 = true;
				switch (this.selected) {
					case 'z':
						break;
					case 'mz':
						this.valuedate = [0, 0, 0];

						this.$nextTick(function() {
							this.week.week = this.dates[this.current];
							let week = this.week.week.split('—');
							let week1 = week[0].split('-');
							week1[0] = parseInt(week1[0]);
							week1[1] = parseInt(week1[1]);
							let weeksM = this.weeksM[week1[0]][week1[1]];
							let ok = false;
							for (let i = 0, len = weeksM.length; i < len; i++) {
								if (weeksM[i].weeksIndex == this.current) {
									let data = [];

									data.push(this.years.indexOf(week1[0]));
									data.push(week1[1] - 1);
									data.push(i);
									this.valuedate = data;
									this.p_currents.mz = data;
									//年月下拉定位
									this.year = week1[0];
									this.month = week1[1];
									// this.p_currents.mz.current=this.current;
									ok = true;
									this.onSwiperDate1 = false;
								}
							}
							let week2 = week[1].split('-');
							if (!ok) {
								week2[0] = parseInt(week2[0]);
								week2[1] = parseInt(week2[1]);
								weeksM = this.weeksM[week2[0]][week2[1]];
								for (let j = 0, len = weeksM.length; j < len; j++) {
									if (weeksM[j].weeksIndex == this.current) {
										let data = [];

										data.push(this.years.indexOf(week2[0]));
										data.push(week2[1] - 1);
										data.push(j);
										this.valuedate = data;
										this.p_currents.mz = data;
										//年月下拉定位
										this.year = week2[0];
										this.month = week2[1];
										// this.p_currents.mz.current=this.current;
										ok = true;
										this.onSwiperDate1 = false;
									}
								}
							}
							this.onSubmit();
						});
						break;

					case 'm':
						this.valuedate = [0, 0];
						this.$nextTick(function() {
							this.month = parseInt(this.dates[this.current]);
							//年月下拉定位
							let data = [];
							data.push(this.years.indexOf(this.year));
							data.push(this.month - 1);
							this.valuedate = data;
							this.p_currents.m = data;
							this.p_currents.m.current = this.current;
							this.onSubmit();
						});
						break;
					case 'y':
						this.valuedate = [0];
						this.$nextTick(function() {
							this.year = parseInt(this.dates[this.current]);
							//年月下拉定位
							let data = [];
							data.push(this.years.indexOf(this.year));
							this.valuedate = data;
							this.p_currents.y = data;
							this.p_currents.y.current = this.current;
							this.onSubmit();
						});
						break;
					case 'd':
						this.valuedate = [0, 0, 0];
						this.$nextTick(function() {
							this.day = parseInt(this.dates[this.current]);
							//天下拉定位
							let data = [];
							//	console.log('天', this.day);
							data.push(this.years.indexOf(this.year));
							data.push(this.month - 1);
							data.push(this.current);
							this.valuedate = data;
							this.p_currents.d = data;
							this.p_currents.d.current = this.current;
							this.onSubmit();
						});
						break;
				}
			},
			onSwiperDate() {
				this.$refs.datePopup.open();
				//滑动查询是ok了，同步下拉开始
				//console.log('onSwiperDate事件>>>>>', this.valuedate, this.p_currents[this.selected].current);

				if (this.selected == 'mz') {
					//点击获取下拉下标 mz下拉不同步问题
					this.valuedate = [];
					this.$nextTick(function() {
						this.valuedate.push(this.p_currents.mz[0]);
						this.valuedate.push(this.p_currents.mz[1]);
						this.valuedate.push(this.p_currents.mz[2]);
					});
				} else if (this.selected == 'm') {
					this.valuedate = [];
					this.$nextTick(function() {
						this.valuedate.push(this.p_currents.m[0]);
						this.valuedate.push(this.p_currents.m[1]);
					});
				} else if (this.selected == 'y') {
					this.valuedate = [];
					this.$nextTick(function() {
						this.valuedate.push(this.p_currents.y[0]);
					});
				} else if (this.selected == 'd') {
					this.valuedate = [];
					this.$nextTick(function() {
						this.valuedate.push(this.p_currents.d[0]);
						this.valuedate.push(this.p_currents.d[1]);
						this.valuedate.push(this.p_currents.d[2]);
					});
				}
			},
			onChangeSwiper(e) {
				//console.log('滑动',e);
				console.log('onChangeSwiper事件>>>>>', this.valuedate, this.p_currents[this.selected].current);
			},
			//点击周 月 年
			onDateType(str) {
				this.dateType = this.selected;
				this.selected = str || this.selected;
				if (this.selected == 'd') {
					this.dates = this.days;
					this.current = this.p_currents.d[2];

					this.year = this.years[this.p_currents.d[0]];
					this.month = this.p_currents.d[1] + 1;
					this.day = this.p_currents.d[2] + 1;
					//提交  需要
					console.log('onDateType天》》', this.year, this.month, this.day, this.p_currents.d);
				}
				if (this.selected == 'z') {
					this.dates = this.weeks;
					this.current = this.currents.z;
				}
				if (this.selected == 'mz') {
					this.dates = this.weeks;

					if (this.p_currents.mz.length < 3) {
						//补齐运算后的 周位数
						this.p_currents.mz.push(this.week.index + 1);
					}
					//由多维度年月确定周  2020   月下标
					this.current = this.weeksM[this.years[this.p_currents.mz[0]]][this.p_currents.mz[1] + 1][this.p_currents.mz[2]].weeksIndex;

					this.year = this.years[this.p_currents.mz[0]];
					this.month = this.p_currents.mz[1] + 1;
				}
				if (this.selected == 'm') {
					this.dates = this.months;
					//提交  需要
					this.year = this.years[this.p_currents.m[0]];
					this.month = this.p_currents.m[1] + 1;
					this.current = this.p_currents.m[1];
				}
				if (this.selected == 'y') {
					this.dates = this.years;
					//提交  需要
					this.year = this.years[this.p_currents.y[0]];
					this.current = this.p_currents.y[0];
				}
				//console.log('onDateType事件>>>>>', this.valuedate, this.p_currents[this.selected].current);
				this.onSubmit('datePopup');
				return;
			},
			//参数标准时间
			init(date) {


				// console.log('weeks', this.weeks);
				// console.log('week', this.week);
				// console.log('days', this.days);
				// console.log('day', this.day);
				//开始计算时间
				this.setDays();
				this.onDateType();
			},
			setDays(date) {
				let dateWeek = date || this.p_currents.d;
				let y = this.years[dateWeek[0]];
				let m = dateWeek[1];
				let prevDate = new Date(y, m, 1);
				let prevDateEnd = new Date(y, m + 1, 0);
				//周一
				let start = this.getWeek1(prevDate);
				this.weeks = []; //上面滑动的
				let i = 0;
				let dateWeeks = null;
				let fun = () => {
					let startTime = new Date(start);
					// console.log('startTime', startTime.getFullYear(), startTime.getMonth(), startTime.getDate())
					// console.log('prevDateEnd', prevDateEnd.getFullYear(), prevDateEnd.getMonth(), prevDateEnd.getDate())
					startTime = startTime.getTime();
					let endTime = prevDateEnd.getTime();

					//console.log('>>> 循环');
					let arr = start.split('-');
					//运算周的开头和结尾
					if (i % 2 == 0) {
						if (arr[0] > this.year) {
							return;
						}
						this.weeks.push(arr[0] + '-' + arr[1] + '-' + arr[2]); //滑动显示的
						this.tmpWeek = arr[1] + '-' + arr[2]; //下拉列表显示的
					} else {
						let str = this.weeks[this.weeks.length - 1];
						//链接   周
						this.weeks[this.weeks.length - 1] = str + ' — ' + arr[0] + '-' + arr[1] + '-' + arr[2];
						this.tmpWeek = this.tmpWeek + ' 到 ' + arr[1] + '-' + arr[2];

						//标记当天所在周
						let start_date = str.split('-');
						if (arr[1] > this.month + 1 && arr[0] == y || start_date[1] > this.month + 1 && start_date[0] == y) {
							return;
						}
						if (this.week.day == false) {
							if (
								(arr[0] == this.year && arr[1] == this.month + 1 && arr[2] >= this.day) ||
								(start_date[0] == this.year && start_date[1] == this.month + 1 && start_date[2] == this.day)
							) {
								this.week.index = this.weeks.length - 1;
								this.week.day = true;
								this.week.week = this.weeks[this.weeks.length - 1];
							}
						}

						//取出每月对应的周数据
						let intY = parseInt(arr[0]);
						let intM = parseInt(arr[1]);
						//如果没有年月处理
						if (!this.weeksM[intY]) {
							this.weeksM[intY] = {};
						}
						if (!dateWeeks) {
							dateWeeks = [];
						} else {
							// this.weeksM[intY][intM].map((car) => {
							// 	console.log('car',car)
							// })

						}

						var data = {
							week: this.tmpWeek,
							weeksIndex: this.weeks.length - 1
						};
						dateWeeks.push(data);

						//当周定位
						if (this.week.day == true && this.currents.mz < 0) {
							this.valuedate[1] = intM - 1;
							this.valuedate[2] = dateWeeks.length - 1;
							this.p_currents.mz[2] = dateWeeks.length - 1;
							this.currents.mz = dateWeeks.length - 1;
							this.current = this.weeks.length - 1;
						}


					}
					i += 1;
					var start1 = new Date(start);
					let start2 = start1.getDay();
					//周日是0,周一6
					if (start2 == 0) {
						start = this.addDate(start1, 1);
					} else {
						start = this.addDate(start1, 6);
					}

					if (startTime >= endTime) {
						//console.log('>>> 推出');
						return;
					}
					fun();
				}
				fun();

				this.weeksM[y][m + 1] = dateWeeks;
				// for (let i = 0; i < 999999; i++) {

				// }

			},
			//上周一 中国标准时间
			getWeek1(date) {
				let nowTime = date.getTime();
				let day = date.getDay() == 0 ? 7 : date.getDay();
				let oneDayLong = 24 * 60 * 60 * 1000;
				let time = nowTime - (day - 1) * oneDayLong;
				let week1 = new Date(time);
				return this.format(week1);
			},
			addDate(date, T) {
				if (T == undefined || T == '') {
					T = 1;
				}
				date.setDate(date.getDate() + T);
				let y = date.getFullYear();
				let m = date.getMonth() + 1;
				let d = date.getDate();
				return y + '-' + this.fill(m) + '-' + this.fill(d);
			},
			//将标准时间 字符串格式化
			format(date) {
				let y = date.getFullYear();
				let m = date.getMonth() + 1;
				let d = date.getDate();
				return y + '-' + this.fill(m) + '-' + this.fill(d);
			},
			//格式化月 字符串格式化
			fill(a) {
				return 10 > a ? '0' + (0 | a) : a;
			},
			//选中日期
			bindChange(e) {
				let val = e.detail.value;
				//左右滑动 后点击，同步下拉时间
				switch (this.selected) {
					case 'z':
						this.week.week = this.weeks[val[0]];
						this.current = val[0];
						this.currents.z = val[0];
						//	this.p_currents.current = this.current;
						//记录本次,不能this.p_currents.z = val;
						break;
					case 'mz':
						this.year = this.years[val[0]];
						this.month = val[1] + 1;
						//处理每月的周
						this.setDays(val);
						//滑动 的周月年同步
						this.current = this.weeksM[this.year][this.month][val[2]].weeksIndex;
						this.currents.y = val[0];
						this.currents.m = val[1];
						this.currents.mz = val[2];
						//记录本次,不能this.p_currents.mz = val;
						//this.p_currents.mz.current = this.current;
						this.p_currents.mz[0] = val[0];
						this.p_currents.mz[1] = val[1];
						this.p_currents.mz[2] = val[2];

						this.week.week = this.weeks[this.p_currents.mz.current];
						break;
					case 'm':
						this.year = this.years[val[0]];
						this.month = val[1] + 1;
						this.current = val[1];
						this.currents.y = val[0];
						this.currents.m = val[1];
						//this.p_currents.m.current = this.current;
						//记录本次,不能this.p_currents.m = val;
						this.p_currents.m[0] = val[0];
						this.p_currents.m[1] = val[1];
						break;
					case 'y':
						this.year = this.years[val[0]];
						this.current = val[0];
						this.currents.y = val[0];
						//this.p_currents.y.current = this.current;
						//记录本次，不能this.p_currents.y = val;
						this.p_currents.y[0] = val[0];
						break;
					case 'd':
						this.year = this.years[val[0]];
						this.month = val[1] + 1;
						this.day = val[2];
						let dateM = new Date(this.year, this.month, 0);
						let dayMax = dateM.getDate();
						this.days = [];
						for (let t = 1; t <= dayMax; t++) {
							this.days.push(t);
						}

						this.current = val[2];
						this.currents.y = val[0];
						this.currents.m = val[1];
						this.currents.d = val[2];
						//记录本次 提交不能this.p_currents.d = val,发现this.valuedate也没有，也会丢失上面的时间滑块的控制
						this.p_currents.d[0] = val[0];
						this.p_currents.d[1] = val[1];
						this.p_currents.d[2] = val[2];
						//this.p_currents.d.current = this.current;
						break;
				}
			}
		}
	};
</script>


